﻿@using Metro.Kashikoi.ServiceContract.Item;
@using Metro.Kashikoi.ServiceContract.Location;
@model Metro.Kashikoi.ServiceContract.Storage.BinInventory
@{
    ViewBag.Title = "MapStockItem";
    ViewBag.MenuId = "locationLink";

    var itemList = (List<StockItem>)ViewBag.Items;
    var stockArea = (StockArea)ViewBag.StockArea;
    var categories = (List<ColorCategory>)ViewBag.Categories;
}
<h2>
    Map a Stock Item to @stockArea.Name</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        <div class="editor-label">
            Select an item
        </div>
        <div class="editor-field">
            @Html.DropDownList("itemList", itemList.Select(item => new SelectListItem { Text = item.Name, Value = item.Id.ToString() }))
        </div>
        <div class="editor-label">
            Select a category
        </div>
        <div class="editor-field">
            @Html.DropDownList("categoryList", categories.Select(cat => new SelectListItem { Text = cat.Name, Value = cat.Id.ToString() }))
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Quantity)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Quantity, new { value = "1" })
            @Html.ValidationMessageFor(model => model.Quantity)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.SplitQuantity)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SplitQuantity, new { value = "1" })
            @Html.ValidationMessageFor(model => model.SplitQuantity)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Unit)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Unit)
            @Html.ValidationMessageFor(model => model.Unit)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.SSID)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SSID)
            @Html.ValidationMessageFor(model => model.SSID)
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    
    <div>
        @*Hidden fields*@
        @Html.HiddenFor(model => model.StockAreaId)
    </div>
}
<div>
    @Html.ActionLink("Back to " + stockArea.Name, "StockArea", new { id = stockArea.Id })
</div>
